/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.mts.client.listener;


import com.google.common.eventbus.Subscribe;
import com.intelligent.mts.client.core.view.MainStatusPanel;
import com.intelligent.mts.client.event.*;
import com.intelligent.mts.client.utils.ApplicationBeanUtils;
import com.intelligent.mts.common.utils.StringUtils;

import java.awt.*;

/**
 * Created by Peter on 2016/7/26.
 */
public class StatusBarListener {
    @Subscribe
    public void receivedMsg(StatusBarChangeEvent event) {
        resetStatusValue(event);
    }

    private void resetStatusValue(StatusBarChangeEvent event) {
        String message = event.getMessage();
        String level = event.getLevel();

        if(message == null) {
            message = "";
        }

        Color color = Color.black;
        if(StatusBarChangeEvent.MSG_LEVEL_ERROR.equals(level)) {
            color = Color.red;
        }

        ApplicationBeanUtils.getBean(MainStatusPanel.class).setStatusValue(message, color);
    }


}
